import { defineStore } from "pinia";
import { setLocalStorage, getLocalStorage } from "@/utils/common";
import constant from "@/constant";
export default defineStore({
  id: "user",
  state: () => {
    return {
      user: getLocalStorage(constant.USER) || {},
      // 用户上一次所在的路由路径
      oldFullPath: "/",
      // 网站浏览量, 强迫症就单独创个文件存
      count: 0
    };
  },
  actions: {
    setUser(user) {
      this.user = user;
    },
    clearUser() {
      this.user = {};
      setLocalStorage(constant.USER, {});
    },
    setOldFullPath(url) {
      this.oldFullPath = url;
    },
    setCount(data) {
      this.count = data
    }
  }
});
